﻿using System;
using System.Collections.Generic;
using System.IO;

namespace OpenLS.Spreadsheet.Formats.Biff.Records
{
    struct XFProps
    {
        private ushort reserved;
        private XfProp[] xfPropArray;

        public void Read(BinaryReader reader)
        {
#if DEBUG
            ReadWriteChecker.CheckStruct((ref XFProps t, BinaryReader r) => t.Read(r), (ref XFProps t, BinaryWriter w) => t.Write(w), reader, ref this);
#endif
            reserved = reader.ReadUInt16();
            ushort cprops = reader.ReadUInt16();
            xfPropArray = new XfProp[cprops];
            for (int i = 0; i < xfPropArray.Length; i++)
            {
                xfPropArray[i].Read(reader);
            }
        }

        public void Write(BinaryWriter writer)
        {
            writer.Write(reserved);
            writer.Write((ushort)xfPropArray.Length);
            foreach (var xfProp in xfPropArray)
            {
                xfProp.Write(writer);
            }
        }

        public XfProp[] GetProps()
        {
            return this.xfPropArray;
        }
    }
}